package com.java8.wangchenyu;


import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

public class Demo03 {
    public static void main(String[] args) {

        List<Student> list = new ArrayList<>();
        Student s1 = new Student();
        s1.setId(1);
        s1.setName("name1");
        s1.setAge(22);
        list.add(s1);
        Student s2 = new Student();
        s2.setId(2);
        s2.setName("name2");
        s2.setAge(66);
        list.add(s2);
        Student s3 = new Student();
        s3.setId(3);
        s3.setName("name3");
        s3.setAge(44);
        list.add(s3);


        list.forEach(s->s.show());  
        list.forEach(Student::show);
        System.out.println();
        list.forEach(s->s1.show2(s));
        list.forEach(s1::show2);

        list.forEach(s-> System.out.println(s));
        list.forEach(System.out::println);

        list.forEach(s-> Student.play(s));
        list.forEach(Student::play);

        /*匿名类的方式*/
        GetStudent gs1 = new GetStudent() {
            @Override
            public Student getStu() {
                return new Student();
            }
        };
        Student stu1 = gs1.getStu();
        /*箭头函数方式*/
        GetStudent gs2 = ()->new Student();
        Student stu2=gs2.getStu();
        /*方法引用的方式*/
        GetStudent gs3 = Student::new;
        Student stu3 = gs3.getStu();


        Supplier<Student> supplier = Student::new;
        Student stu4 = supplier.get();

        Supplier<Demo01> sd = Demo01::new;
        Demo01 d1 = sd.get();

    }
}
